import Vuex from 'vuex'
const configure={
    state:{
        //HOST:'http://127.0.0.1:8089',//后台
        HOST:'http://39.103.156.157:8089',
        photoUrl:'http://39.103.156.157/resource/',
        activeName:'',//当前菜单名
        loginIn:false, //是否已登录
        isActive:false,



    },

    getters:{

        activeName: state => {
            let activeName=state.activeName;
            if(!activeName){
                activeName=JSON.parse(window.sessionStorage.getItem('activeName'))
            }
            return activeName
        },
        loginIn: state=>{
            let loginIn=state.loginIn;
            if (!loginIn){
                loginIn=JSON.parse(window.sessionStorage.getItem('loginIn'))
            }
            return loginIn
        },
        isActive: state=>{
            let isActive=state.isActive;
            if (!isActive){
                isActive=JSON.parse(window.sessionStorage.getItem('isActive'))
            }
            return isActive
        },



    },
    mutations:{
        setActiveName:(state,activeName)=>{
            state.activeName=activeName;
            window.sessionStorage.setItem('activeName',JSON.stringify(activeName))
        },
        setLoginIn:(state,loginIn)=>{
            state.loginIn=loginIn;
            window.sessionStorage.setItem('loginIn',JSON.stringify(loginIn))
        },
        setIsActive:(state,isActive)=>{
            state.isActive=isActive;
            window.sessionStorage.setItem('isActive',JSON.stringify(isActive))
        }

    }

}
export default configure